/**
 * Copyright (C), 2015, 上海赛可电子商务有限公司
 * Author:   康明飞
 * Date:     2015-4-29
 * Description: 详情页
 */
window.monitorVersion="v160120";

;(function($){
	detailPage = {
		init : function(){
			window.g_config = window.g_config||{};
			this.preceptTable.TablePos();//金融方案表格定位
			this.addTimeCutDownEvent();

			//this.addCarGiftEvent();
			//this.addSaleCityEvent();

			//爬虫数据展示
			//this.chartShow();

			//收藏
			this.addFavorEvent();

			//发送到手机
			this.addSendMobileEvent();

			//给提交按钮加hover态
			this.addOrderButtonMouseEvent();

			//参数配置
			this.addCarConfigEvent();

			//固定表头
			this.addFixedHeaderEvent();

			//百度分享
			var self=this;
			setTimeout(function(){
				self.addBaiduShareEvent();
			},500);

			this.addHistoryEvent();
			//01-27迭代，免费咨询
			this.freeConsultation();

			//二手车入口
			this.usedCarEnter();
			this.constituteMoney();
			//同级别推荐
			this.seriseSizeRecemmend();
			//猜你喜欢
			this.guessYouLikes();
			//this.crawlerDataShowAsync();
			//图片懒加载
			$("img.lazy").lazyload({effect: "fadeIn"});
			//ECar.tooltip();

			//显示掩藏88节 入口
			this.active88();
		},

		active88:function(){

			var 	giftCont = $('#js_gift_cont'),
			 	giftBox =  $('#js_gift_box'),
			 	footerNode = $('#js_cxgb_site_footer');

			$(window).scroll(function(){
				if(($(window).scrollTop() + 653 ) >footerNode.offset().top){
					giftBox.hide();
				} else{
					giftBox.show();
				}
			});

		},

		seriseSizeRecemmend:function(){
			var seriesSizeRecemmendUrl = "/product/samePriceRecemmend/" + spuId + "/" + window.barePrice + "/" + channelId + ".htm";
			$("#seriesSizeRecemmend").load(seriesSizeRecemmendUrl,function(){
				$("img.lazy").lazyload({effect: "fadeIn"});
			});
		},
		guessYouLikes:function(){
			var guessYouLikesUrl = "/product/guessYouLikes/" + spuId + "/" + velSeriesId + "/" + channelId + ".htm";
			$("#carGuessYouLike").load(guessYouLikesUrl,function(){
				$("img.lazy").lazyload({effect: "fadeIn"});
			});
		},
		crawlerDataShowAsync:function(){
			/*爬虫初步异步化-良*/
			var crawlerDataUrl = "/product/showAsyncCrawlerModelView.htm?spuId=" + spuId + "&serachNum=5";
			//var crawlerDataUrl = "/mscarmall/mall/js/test-data/showAsyncCrawlerModelView.html";
			$("#crawlerAsync-append").load(crawlerDataUrl);
		},
		constituteMoney:function(){
			//让子元素的高度和父级元素的高度相同；
			var oHeight = $(".constitute-money").height();
			 $(".constitute-money").children().css("height",oHeight);
			 $(".top-triangle").css("height","0");

			$(".money-hover").hover(function(){
				$(".constitute-money").show();
			},function(){
				$(".constitute-money").hide();
			});
		},
		//二手车入口
		usedCarEnter:function(){
			$(".show-used-car").on("click",function(){
				var usedCarForm=$("#used-car-enter").html();
				ECar.easyDialog.open({
					container : {
						header : window.g_config.secondHandCarGiftTitle||" ",
						content:usedCarForm
					},
					success:function(){
						//唤醒埋点
						var md = new Analytics();
						md.scan();
					}
				});
				$("#easyDialogTitle").css("font-size","18px");
			});
		},
		//金融方案表格定位
		preceptTable:{
			tdLength:'', ////表格列数;
			TablePos:function(){

				var tableTypeA = $(".car-insurance-table[type=type-a]"),
					tdLength = $(tableTypeA).find(".table td").length,
					tableContWidth = $('.table-cont').width(),
					colBtn = "<span class='col-l'></span><span class='col-r'></span>",
					tableBoxHeight = $(tableTypeA).find(".table-title-list").height(),  //获取tableBox高度;
					flag = true;//动画标识

				$(tableTypeA).find(".table").css("width",tableContWidth);
				if(tdLength == 1){
					$(tableTypeA).find(".table").addClass("table-one");
				}
				else if(tdLength == 2){
					$(tableTypeA).find(".table").addClass("table-two");
				}else if(tdLength >= 3){
					$(tableTypeA).find(".table").addClass("table-three");
				}
				$(tableTypeA).find(".table-cont").css("height",tableBoxHeight+"px");
				if($(".car-insurance-table[type=type-b]").index() > 0){
					var tableTypeB = $(".car-insurance-table[type=type-b]");
					var tableBoxHeightB = $(tableTypeB).find(".table-title-list").height();//获取tableBox高度;
					$(tableTypeB).find(".table").css("width",tableContWidth);
					$(tableTypeB).find(".table-cont").css("height",tableBoxHeightB+"px");
				}
				this.tdLength = $(tableTypeA).find(".table-box td").length;//获取表格列数;
				if(this.tdLength == 1){                         //判断列数
					$(tableTypeA).find(".table-box .table").addClass("table-one");
				}else if(this.tdLength == 2){
					$(tableTypeA).find(".table-box .table").addClass("table-two");
				}else if(this.tdLength > 3){
					$(tableTypeA).find(".table-box .table").addClass("table-three");
					$(tableTypeA).find(".table-box .table").css("width",this.tdLength * Math.floor(tableContWidth / 3)+"px");
					$(tableTypeA).append(colBtn);
					$(".col-l,.col-r").on("click",function(){
						if(flag){
							flag = false;
							detailPage.preceptTable.tableMove(this);
							setTimeout(function(){
								flag = true;
							},400);
						}else{
							return false;
						}
					});

				}
			},
			tableMove:function(elm){

				var maxMoveNb = detailPage.preceptTable.tdLength - 3; //超出列数
				var boxRight = parseInt($(".table-box").css("left"));
				var tableContWidth = $('.table-cont').width();
				var maxPos = maxMoveNb * Math.floor(tableContWidth / 3); //总偏移量

				if($(elm).attr("class") == "col-r"){
					$(".table-box").animate({left:boxRight - Math.floor(tableContWidth / 3)+"px"},300,function(){
						boxRight = parseInt($(".table-box").css("left"));
						//console.log(Math.abs(boxRight) >= maxPos);

						if(Math.abs(boxRight) > 0){
							$(".car-insurance-table .col-l").css("display","block");
						}
						if(Math.abs(boxRight) == maxPos){
							$(".car-insurance-table .col-r").css("display","none");
						}
					});

				}else if($(elm).attr("class") == "col-l"){
					$(".table-box").animate({left:boxRight + Math.floor(tableContWidth / 3)+"px"},300,function(){
						boxRight = parseInt($(".table-box").css("left"));
						if(Math.abs(boxRight) < maxPos){
							$(".car-insurance-table .col-r").css("display","block");
						}
						if(Math.abs(boxRight) === 0){
							$(".car-insurance-table .col-l").css("display","none");
						}
					});
				}
			}
		},
		//2016-01-17商城迭代 免费咨询按钮
		freeConsultation:function(){

			var self = this;
			$(".js_help_service").on("click",function(){
				//免费咨询监控
				var img = new Image(1,1),
				ca=monitorVersion+"_cm-product_pc_car-main_c2r5d2$免费咨询$";
				img.src =  ('https:' == document.location.protocol ? 'https' : 'http')+'://data.chexiang.com/ca.gif?'+'&ca='+ca+"&_v="+new Date();

				var $freeConsultation = $('#free-consultation').html();
				ECar.easyDialog.open({
					container : {
						header : "免费咨询",
						content:$freeConsultation
					}
				});
				$(".easyDialog_wrapper .easyDialog_text").css("padding","0");
				//三级联动
				$.ajax({
					url:"/commonAjax/getMultiMenu.htm",
					type: "GET",
					dataType: "json",
					success: function(data){
						var e_data= eval("("+data+")");
						ECar.seriesSelect($(".popup-input-box","#easyDialogWrapper"),{
							/*url:" http://car.chexiang.com/commonAjax/getMultiMenu.htm",*/
							data:e_data,
							nodata:null,
							required:false,
							selects:["car-brand","car-series","car-model"],
							complete:function(){

							}
						});
					}
				});

				//品牌  车系 车型
				function verifySel(sClass){
					$('.'+sClass).on('change',function(){
						judge(sClass);
					});
				}
				function judge(sClass){
					var Val = parseInt( $('.'+sClass).val() ),
							type = 0;
					if(!Val){
						$('.'+sClass).parent('.select').next('span').show();
						type = 0;
					}else{
						$('.'+sClass).parent('.select').next('span').hide();
						type = 1;
					}
					return type;
				}
				verifySel('car-brand');
				verifySel('car-series');
				$(".input-btn").on("click",function(){
					// 选中的text值,选中的value值
					var param={},
						brandText = $(".car-brand option").not(function(){ return !this.selected; }).text(),
						seriesText = $(".car-series option").not(function(){ return !this.selected; }).text(),
						modelText = $(".car-model option").not(function(){ return !this.selected; }).text(),
						brandVal = $(".car-brand").val(),
						seriesVal = $(".car-series").val(),
						modelVal = $(".car-model").val(),
						phoneNum = $.trim( $(".telephone").val() ),
						userName = $.trim( $(".user-name").val() );
						param["velBrandName"]=brandText,
						param["velSeriesName"]=seriesText,
						param["velModelName"]=modelText,
						param["velBrandId"]=brandVal,
						param["velSeriesId"]=seriesVal,
						param["velModelId"]=modelVal,
						param["mobile"]=phoneNum,
						param["userName"]=userName;
						var carBrandResult=judge('car-brand'),
						carSeriesResult=judge('car-series'),
						phoneResult=verifyPhone(),
						nameResult=verifyName();
						//console.log(JSON.stringify(param) );
					if( carBrandResult&&carSeriesResult&&phoneResult&&nameResult ){
						$.ajax({
							url:'/promotion/saveUserMsg.htm',
							type:'post',
							data:param,
							success:function(data){
								if(data>0) {
									self.showCommonTips("已经收到您提交的问题，车享顾问会及时跟您沟通的，请确保手机畅通。");
								}else {
									if(data == -1){
										//试乘试驾留资时，必须输入手机号和活动编号。
										self.showCommonTips("您提交的信息有误，请重新填写。");
									}else if(data == -2){
										//该手机号码已在该活动中留资。
										self.showCommonTips("您已留资成功，不需要重复提交。");
									}else{
										self.showCommonTips("网络原因，请重新填写申请。");
									}
								}

							},
							error: function(){
								/*ECar.easyDialog.open({
									container : {
										header : "免费咨询",
										content:"网络原因，请重新填写申请"
									}
								});
								setTimeout(function(){
									ECar.easyDialog.close();
								},3000);*/
								self.showCommonTips("网络原因，请重新填写申请。");
							}
						});
					}
					return false;

				});
				//姓名验证
				$(".user-name").on("blur",verifyName);
				function verifyName(){
					var userName = $.trim( $(".user-name").val() ),flag = 0;
					if(!userName){
						$(".user-name").next('span').show().text('请输入您的姓名');
						flag = 0;
					}else if( !testName(userName) ){
						$(".user-name").next('span').show().text('请输入12位中文或者英文姓名');
						flag = 0;
					}else{
						$(".user-name").next('span').hide().text(' ');
						flag = 1;
					}
					return flag;
				}
				var nameReg = /([\u4e00-\u9fa5]|([a-zA-Z]| )+)/;
				//姓名检验
				function testName(name){
					var name = $.trim(name);
					var nameArray = name.split("");
					var type = true;
					for(var i = 0;i<nameArray.length;i++){
						if(!nameReg.test(nameArray[i])){
							type = false;
						}
					}
					return type;
				}
				//手机号验证
				$(".telephone").on("blur",verifyPhone);
				function verifyPhone(){
					var phoneNum = $.trim( $(".telephone").val() ),
						phoneReg = /^1[3,4,5,7,8]\d{9}/,
						flag = 0;
					if(!phoneNum){
						$(".telephone").next('span').show().text('请输入您的手机号码');
						flag = 0;
					}else if( !phoneReg.test(phoneNum) ){
						$(".telephone").next('span').show().text('请输入正确的11位电话号码');
						flag = 0;
					}else{
						$(".telephone").next('span').hide().text(' ');
						flag = 1;
					}
					return flag;
				}
			});

		},
		//立即下定按钮是否绑定提交事件
		submitBtnBindEventFlag:false,
		//倒计时
		addTimeCutDownEvent: function(){
			var timeInfoNode = $(".time-info");
			var self = this;
			var options= {
				serverTime: window.g_config.serverTime || 0,
				startTime: window.g_config.startTime || 0,
				stopTime: window.g_config.stopTime || 0,
				notStartCallBack: function(){
					// $(".submit_preorder").removeClass("btn-submit").addClass("btn-submit-nostart").unbind("click").html("未开始");
				},
				startCallBack: function(timeStampObj){
					// if(!self.submitBtnBindEventFlag){
					// 	$(".btn-submit-nostart").removeClass("btn-submit-nostart").addClass("btn-submit").unbind("click").html("立即下定");
					// 	self.addOrderButtonClickEvent();
					// 	self.submitBtnBindEventFlag = true;
					// }
					var timtInfoText="剩余"+ timeStampObj.day + "天"
										+ timeStampObj.hour +"时"
										+ timeStampObj.minute + "分"
										+ timeStampObj.second + "秒";
					timeInfoNode.html(timtInfoText);
					if(timeStampObj.day>=7){
						timeInfoNode.hide();
					}else{
						timeInfoNode.show();
					}
				},
				//结束时回调函数
				stopCallBack: function(){
					timeInfoNode.html("剩余0天0时0分0秒");
					// $(".submit_preorder").removeClass("btn-submit submit_preorder").addClass("btn-submit-sellout").unbind("click").html("已结束");
				}
			};
			ECar.timeZone(options);
		},
		getCookie: function(key) {
			var result = document.cookie.match(new RegExp("(^| )" + key + "=([^;]*)"));
			return result != null ? decodeURIComponent(result[2]) : null;
		},
		//选择城市
		addSaleCityEvent: function(){
			//选择城市
			var cityNodes = $(".sale-city .city-list a");
			if(cityNodes.length>1){
				var cookieCityId = this.getCookie("city.id");
				var hiddenNode = $("#hidden_data");
				cityNodes.each(function(index){
					if(cookieCityId == $(this).data("code")){
						$("#sale-city-name").html($(this).data("name"));
						hiddenNode.attr("cityId",$(this).data("code"));
						return false;
					}
				});
				cityNodes.click(function(){
					$("#sale-city-name").html($(this).data("name"));
					hiddenNode.attr("cityId",$(this).data("code"));
				});

				var cityList = $(".city-list");
				var saleCity = $(".sale-city li");
				saleCity.on("click",function(e){
					saleCity.find("i").removeClass("cur");
					if(cityList.css("display")=="none"){
						cityList.show();
						$(this).find("i").addClass("cur");
					}else{
						cityList.hide();
					}
					e.stopPropagation();
				});
				cityList.on("click",function(e){
					e.stopPropagation();
					saleCity.find("i").removeClass("cur");
					$(this).hide();
				});
				$(document).on("click",function(e){
					cityList.hide();
					saleCity.find("i").removeClass("cur");
				});
			}
		},
		//gift add Event
		addCarGiftEvent: function(){
			function addHoverOnGiftNodes(){
				var msgNodes = $(".gift-bag .msg");
				msgNodes.css("opacity",0.3);
				$(".gift-bag li").hover(function(){
					$(".gift-bag .msg:visible").hide().css("opacity",0.3);
					$(this).find(".msg").show().animate({opacity:0.7});
				},function(){
					$(this).find(".msg").hide().css("opacity",0.3);
				});
			}
			addHoverOnGiftNodes();
			var giftNodes = $(".gift-bag li");
			giftNodes.click(function(){
				if(!$(this).hasClass("cur")){
					giftNodes.removeClass("cur");
					$(this).addClass("cur");
				}
			});
		},
		//favor
		addFavorEvent: function(){
			var self = this;
			//是否登陆
			var hasLogin = this.getCookie("sc_s")!=null;
			$(".add-favor").click(function(){
				var flagHasFavor = $(this).hasClass("add-collection");
				if(flagHasFavor){
					if(!hasLogin){
						window.backCallName="goAddCollection";
						checkLogin(MALL.accountQuickBase,'B');
					}else{
						self.goAddCollectionDetail();
					}
				}else{
					if(!hasLogin){
						window.backCallName="goCancelCollection";
						checkLogin(MALL.accountQuickBase,'B');
					}else{
						self.goCancelCollectionDetail();
					}
				}
			});
		},
		goAddCollectionDetail: function(callback){
			var self = this;
			//0：收藏成功;1：已经收藏 ; 2 收藏失败
			$.ajax({
				url: "/product/addCollection.htm",
				type: "POST",
				data:{
					spuId:spuId,
					channelId:channelId
				},
				dataType: "text",
				success: function(data){
					var favorNode = $(".collection-haslogin");
					if(data == 0 || data == 1){
						if(favorNode.length>0){
							favorNode.removeClass("add-collection").addClass("cancel-collection");
							favorNode.find("em").html("取消收藏");
						}else{
							if(data = 0){
								self.showCommonTips("收藏成功");
							}else{
								self.showCommonTips("已经收藏");
							}
							window.location.reload();
						}
					}else{
						self.showCommonTips("收藏失败");
						if(favorNode.length==0){
							window.reload();
						}
					}
				}
			});
		},
		goCancelCollectionDetail: function(callback){
			var self = this;
			$.ajax({
				url: "/product/deleteCollection.htm",
				type: "POST",
				data:{
					spuId:spuId
				},
				dataType: "text",
				success: function(data){
					var favorNode = $(".collection-haslogin");
					if(data=="true"){
						if(favorNode.length>0){
							favorNode.removeClass("cancel-collection").addClass("add-collection");
							favorNode.find("em").html("收藏");
						}else{
							self.showCommonTips("取消收藏成功");
							window.location.reload();
						}
					}else{
						self.showCommonTips("取消收藏失败");
						if(favorNode.length==0){
							window.reload();
						}
					}
				}
			});
		},
		//send mobile
		addSendMobileEvent: function(){
			$(".send-mobile").on("click",function(){
				var txt = $(this).find("em").html();
				if(txt == "发送到手机"){
					$(this).find("em").html("已发送");
				}else{
					$(this).find("em").html("发送到手机");
				}
			});
		},
		//submit button hover css
		addOrderButtonMouseEvent: function(){
			$(".btn-submit").hover(function(){
				$(this).addClass("hover");
			},function(){
				$(this).removeClass("hover");
			})
		},

		//通用提示
		showCommonTips: function(msg){
			ECar.easyDialog.open({
				autoClose : 2000,
				container : {
					header : null,
					content : '<div class="tips-common">'+msg+'</div>'
				}
			});
		},
		//已经下单的提示
		showHasOrderTips: function(){
			ECar.easyDialog.open({
				container : {
					header : '提示',
					content : '<div class="tips-hasorder">尊敬的客户，由于您已经定购了该款车辆，请完成支付或者取消定单后再次购买，给您带来的不便还请谅解。<a onclick="ECar.easyDialog.close()" class="button-blue" target="_blank" href="'+memberBase+'/member/entireCarOrderFor.htm">查看我的定单</a></div>'
				}
			});
		},
		//参数配置
		addCarConfigEvent: function(){
			$(".float-box-left").click(function(){
				if($(".fixed-box-right").hasClass("right")){
					$(".float-box-left").animate({left:"0"},500,function(){
						$(".float-box-left").css("z-index","11");
						$(".float-box-right").css("z-index","12");
					});
					$(".float-box-right").animate({left:"118px"},500);
					$(".fixed-box-right").removeClass("right");
				}
			});
			$(".float-box-right").click(function(){
				if(!$(".fixed-box-right").hasClass("right")){
					$(".float-box-left").animate({left:"118px"},500,function(){
						$(".float-box-left").css("z-index","12");
						$(".float-box-right").css("z-index","11");
					});
					$(".float-box-right").animate({left:"0"},500);
					$(".fixed-box-right").addClass("right");
				}
			});
			var configTabs=$(".config-box ul li");
			var configInfos=$(".content .config-info");
			configTabs.each(function(i){
				$(this).click(function(){
					$('.config-box ul li.hover').removeClass("hover");
					$(this).addClass("hover");
					$('.content .config-info.on').removeClass("on");
					configInfos.eq(i).addClass("on");
				});
			});
		},
		//Cookie Common Class
		getCookie: function(key) {
			var result = document.cookie.match(new RegExp("(^| )" + key + "=([^;]*)"));
			return result != null ? decodeURIComponent(result[2]) : null;
		},
		setCookie: function(key, value, expireDay) {
			if (expireDay) {
				var date = new Date();
				date.setTime(date.getTime() + expireDay * 24 * 3600 * 1000);
				document.cookie = key + "=" + encodeURIComponent(value) + ";path=/;expires=" + date.toGMTString();
			} else {
				document.cookie = key + "=" + encodeURIComponent(value) + ";path=/";
			}
		},
		//添加浏览记录事件
		addHistoryEvent: function(){
			var cookieName = "MALL_HISTORY";
			var historyList = this.getCookie(cookieName);
			if(spuId){
				if(!historyList){
					this.setCookie(cookieName,spuId,365);
				}else{
					historyList = ","+historyList+",";
					historyList = spuId + historyList.replace(","+spuId+",",",");
					var historyArray = historyList.split(',');
					var count = 0,tempHistoryArray=[];
					for(var i=0,len=historyArray.length;i<len;i++){
						var _spuId=historyArray[i];
						if(_spuId!=""){
							tempHistoryArray.push(_spuId);
							count++;
						}
						if(count>=4){
							break;
						}
					}
					this.setCookie(cookieName,tempHistoryArray.join(','),365)
				}
			}
		},
		//固定表头
		addFixedHeaderEvent: function(){
			var titleTops;
			var navTitles=$(".mod-tit");
			function initNavTitlesTop(){
				titleTops=[];
				navTitles.each(function(){
					titleTops.push($(this).offset().top);
				});
			}
			function scrollWindow(y, duration) {
				// 若duration为0, 则直接滚到对应位置
				duration = duration || 300;
				$("html, body").stop().animate({
					scrollTop: y + 1
				}, duration);
			}
			window.onload=function(){
				initNavTitlesTop();
				//是否被点击
				var flagClick=false;
				var fixedNavs=$(".car-info-tabs .fixed-tab");
				var carTabIndex=0;
				var carFixedNav=$(".car-info-tabs");
				var carInfoComment=$(".car-info-comment");
				var fiexedNavTop = $(".car-info-list").offset().top;
				var headerHeight=carFixedNav.outerHeight()+5;
				$(".goto-details").click(function(){
					var detailNodeTop = $(".car-detail-title").offset().top-headerHeight;
					scrollWindow(detailNodeTop,800);
				});
				var fixedOtherTabs = $(".fixed-tab-other");
				function showFixedOtherTabsByScreenWidth(){
					var screenWidth = $(window).width();
					if(screenWidth <= 850){
						if(screenWidth>720){
							fixedOtherTabs.eq(0).fadeOut();
							fixedOtherTabs.eq(1).fadeIn();
							fixedOtherTabs.eq(2).fadeIn();
						}else if(screenWidth>600){
							fixedOtherTabs.eq(0).fadeOut();
							fixedOtherTabs.eq(1).fadeOut();
							fixedOtherTabs.eq(2).fadeIn();
						}else{
							fixedOtherTabs.fadeOut();
						}
					}else if($(document).scrollTop()>fiexedNavTop){
						fixedOtherTabs.fadeIn();
					}else{
						fixedOtherTabs.fadeOut();
					}
				}
				$(window).resize(function(){
					showFixedOtherTabsByScreenWidth();
				});
				$(window).scroll(function() {
					var windowTop=$(document).scrollTop();
					if(windowTop>fiexedNavTop){
						carFixedNav.css({
							"position" : "fixed",
							"top" : "0",
							"zIndex": "20"
						});
						carInfoComment.css("paddingTop","36px");
					}else{
						carFixedNav.css("position","relative");
						carInfoComment.css("paddingTop","0");
					}
					showFixedOtherTabsByScreenWidth();
					if(!flagClick){
						var scrollTop=windowTop+headerHeight;
						var fixedSelectedNav=$(".car-info-tabs li.cur");
						for(var i=0;i<titleTops.length;i++){
							if((i!=titleTops.length-1&&scrollTop>=titleTops[i]&&scrollTop<titleTops[i+1])||(i==titleTops.length-1&&scrollTop>=titleTops[i])){
								if(fixedNavs.eq(i)!=fixedSelectedNav){
									fixedSelectedNav.removeClass("cur");
									fixedNavs.eq(i).addClass("cur");
									carTabIndex=i;
								}
								break;
							}
						}
					}
				});
				/*固定表头*/
				fixedNavs.each(function(i){
					$(this).click(function(){
						if(i!=carTabIndex){
							carTabIndex=i;
							$(".car-info-tabs li.cur").removeClass("cur");
							fixedNavs.eq(i).addClass("cur");
							flagClick=true;
							scrollWindow(titleTops[i]-headerHeight,800);
							setTimeout(function(){flagClick=false;},1000);
						}
					})
				});
			};
		},
		//百度分享
		addBaiduShareEvent: function(){
			window._bd_share_config={
				"common":{
					"bdSnsKey":{},
					"bdText":"",
					"bdMini":"1",
					"bdMiniList":false,
					"bdPic":"",
					"bdStyle":"0",
					"bdSize":"24"
				},
				"share":{}
			};
			with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
		},
		/*	爬虫数据展示	-贺鑫伟	*/
		chartShow: function(){
			var show = false;
			$('.price-trend').mouseover(function(){
//				if(!isCrawlerLoad){
//					crawlerAsync();
//				}
				$('.chart-container').css("display", "block");
				$('.price-tips').css("display", "none");
				//埋点
				var img = new Image(1,1),
				ca = "v160321_cm-product_pc_car-main_c2r1d1$priceTrend$hover";
				img.src =  ('https:' == document.location.protocol ? 'https' : 'http')+'://data.chexiang.com/ca.gif?'+'&ca='+ca+"&_v="+new Date();

			});
			$('.price-trend').mouseout(function(){
				if (show)
					return;
				$('.chart-container').css("display", "none");
				$('.price-tips').css("display", "block");
			});
			$('.price-trend').click(function(){
				show = !show;
			});
			$(document).click(function(e){
				if ($(e.target).parents("a")[0] != $('#price-trend')[0]) {
					show = false;
					$('.chart-container').css("display", "none");
					$('.price-tips').css("display", "block");
				}
			});

			$('.price-tips-close').click(function() {
				$('.price-tips').css("visibility", "hidden");
			});
			$('.price-tips-close')[0].style.cursor="pointer"
		}

	};
	detailPage.init();
})(jQuery);